package l1j.server.server.command.executor;


import l1j.opqlo.Server.L1World.L1World;
import l1j.server.server.model.L1Object;
import l1j.server.server.model.L1Teleport;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.serverpackets.S_SystemMessage;

public class L1ToMon implements L1CommandExecutor {
	public static L1ToMon getInstance() {
		return new L1ToMon();
	}

	private L1ToMon() {
	}

	// @Override
	@Override
	public void execute(final L1PcInstance pc, final String cmdName, final String arg) {
		try {
			final int npcid = Integer.parseInt(arg);//npcid
			for(final L1Object target : L1World.getInstance().getObject()){
				if(target.getId()==npcid){

					L1Teleport.teleport(pc, target.getX(), target.getY(),target.getMapId(), 5, false);
					pc.sendPackets(new S_SystemMessage(new StringBuilder().append(arg).append("移動到怪物身邊。").toString()));
					return;
				}
			}
				pc.sendPackets(new S_SystemMessage(new StringBuilder().append(arg).append("不在線上。").toString()));

		} catch (final Exception e) {
			pc.sendPackets(new S_SystemMessage(cmdName + " 怪物物件編號 請輸入。"));

	}
	}
}